home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / DELPHI.SWG / 0023_Scroll your form with pgUP and pgDn.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  764 b   |  24 lines

  1. {
  2. Q.   How can you do scrolling functions in a TForm component
  3. using  keyboard commands?  For example, scrolling up and down
  4. when a  PgUp or PgDown is pressed.  Is there some simple way to
  5. do this or does it have to be programmed by capturing the
  6. keystrokes and manually responding to them?
  7.  
  8. A.    Form scrolling is accomplished by modifying the
  9. VertScrollbar  or HorzScrollbar Postion properties of the
  10. form.  The following code demonstrates how to do this:
  11. }
  12.  
  13. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  14. Shift: TShiftState);
  15. const
  16.   PageDelta = 10;
  17. begin
  18.   With VertScrollbar do
  19.     if Key = VK_NEXT then
  20.       Position := Position + PageDelta
  21.     else if Key = VK_PRIOR then
  22.       Position := Position - PageDelta;
  23. end;
  24.